﻿/*
 * 版 本 v1.0
 * Copyright (c) 2013-2018 广州市同慧信息科技有限公司
 * 创建人：ftquan
 * 日 期：2017.04.18
 * 描 述：查看模型计算结果
 */

var keyValue = request('modelId');
var warnId = request('warnId');
var companyId = request("companyId");
var kjnd = request("kjnd");
var pzrq = request("pzrq");
var skrName = decodeURI(request("skrName"), "UTF-8");
var amount = request("amount");

var userdefault = {};
var selectedRow;

var bootstrap = function ($, learun) {
    "use strict";

    var jfGrid1 = null;

    var page = {
        init: function () {
            page.bind();
            page.initData();
        },
        bind: function () {
            // 优化滚动条
            $('.lr-layout-wrap').lrscroll();
            $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
                // 调用后台查询
                // queryJson 查询条件
                page.search(queryJson);

            }, 200, 888);

            // 支付明细
            jfGrid1 = $('#payGrid').jfGrid({
                headData: [
                  {label: '单位名称', name: 'companyName', width: 160, align: 'left'},
                  {label: "会计年度", name: "kjnd", width: 50, align: "center"},
                  {label: "凭证日期", name: "pzrq", width: 100, align: "center"},
//                  {label: "支付时间", name: "zfrq", width: 140, align: "center"},
                  {label: "凭证号", name: "pzh", width: 170, align: "center"},
                  {label: '收款人', name: 'skrName', width: 200, align: 'left'},
                  {
                      label: '金额', name: 'amount', width: 110, align: 'right', statistics: true,
                      formatter: function (cellvalue) {
                          return $.formatMoney(cellvalue, 2)
                      }
                  },
                  {label: '用途', name: 'zy', width: 260, align: 'left'},
                  {label: '机构id', name: 'companyId', width: 1, align: 'right', hidden: true}
                ],
                isPage: true
            });

        },
        initData: function () {
            if (!!keyValue) {
              page.search();
            }
        },
        search: function (param) {
            param = param || {};
            param.companyId = companyId;
            param.kjnd = kjnd;
            param.amount = amount;
            param.skrName = skrName;
            param.pzrq = pzrq;
            var name = $("#name").val();
            param.name = name;

            page.refreshData(param);
        },
        refreshData: function (param) {
            learun.httpAsync('GET', config.base_server() + 'sourcebasebusinesspays/findAll?modelId=' + keyValue + '&access_token=' + config.getToken().access_token, param, function (data) {
                $('.lr-layout-wrap').lrSetFormData(data);
                //$("#modelName").html(data.modelName);
                $('#payGrid').jfGridSet('refreshdata', data);
            });
        }
    };

    page.init();
}
